// smsservice.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "log4cplus_switch.h"
#include <common/Pool.h>
#include <string>
#include <list>
#include <map>
#include "netlib/TcpClient.h"
#include "netlib/TcpServer.h"
#include "netlib/SocketEngine.h"
#include "cmpp_define.h"
#include "IF.h"
#include "CMPPClient.h"
#include "netlib/UDPClient.h"
#include <common/Pool.h>
#include "SMSItem.h"
#include "SMSDispatch.h"
#include  "SMSQueue.h"
#include "Account.h"
#include "AccountManager.h"
#include "IF.h"
#include "IFManager.h"
#include "SMSApp.h"

LOG4CPLUS_IMPLEMENT( _g_logger, "global" );

int main(int argc, char* argv[])
{
	//init LOG
	LOG4CPLUS_INIT("prop.txt");
    LOG4CPLUS_INFO( _g_logger, "SMS Service Application Start" );

	WSADATA wsd;
	int nResult = WSAStartup(MAKEWORD(2,2), &wsd);
	if (0 != nResult)
	{
		LOG4CPLUS_ERROR( _g_logger, "WSAStartup() failed" );
		return FALSE;
	}
	
// 	CSocketEngine engine;
// 	CTCPClient* pClient = new CTCPClient();
// 	CTCPServer<CTCPClient>* pServer = new CTCPServer<CTCPClient>();
//	pClient->Connect("192.168.9.49", 17788, 3000);
//	engine.Add(pClient);
	
//  	pServer->CreateServer(8080);
//  	engine.Add(pServer);
// 
//  	CCMPPClient* pCMPPClient = new CCMPPClient();
// 	pCMPPClient->Connect("192.168.9.49", 7890, 3000);
// 	engine.Add(pCMPPClient);
// 
	BOOL bBd=TRUE;

	CSMSApp* pApp = CSMSApp::GetInstance();
	pApp->SubmitSMSTest();
    while (1)
    {
// 		engine.Select();
// 		pCMPPClient->PeriodDispatch();
		pApp->PeriodDispatch();
		Sleep(100);
	}

	//Cleanup Socket
	WSACleanup();
    LOG4CPLUS_INFO( _g_logger, "SMS Service Application Ended" );

	return 0;
}

